
import { _decorator, Component, Node, Vec3, Prefab, Quat, ModelComponent, math, geometry, quat } from 'cc';
import {LogicManager} from "./logicManager";
import {Constant} from "../framework/constant";
import {Player} from "./GameState";
import {ClientEvent} from "../framework/clientEvent";
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = PlayerLogic
 * DateTime = Sat Dec 18 2021 15:55:12 GMT+0800 (中国标准时间)
 * Author = yly1234560
 * FileBasename = playerLogic.ts
 * FileBasenameNoExtension = playerLogic
 * URL = db://assets/scripts/core/playerLogic.ts
 * ManualUrl = https://docs.cocos.com/creator/3.3/manual/zh/
 *
 */
 
@ccclass('PlayerLogic')
export class PlayerLogic extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;

    private _parent: LogicManager = null!;


    start () {
        // [3]
    }

    public init(parent: LogicManager) {
        this._parent = parent;
    }

    /**
     * 生成虚拟玩家
     * @returns 虚拟玩家数据
     */
    public initPlayer() {
        let players: Array<Player>= [];
        for(let i: number = 0; i < Constant.MAX_PLAYER; i++) {
            let player: Player = {} as Player;
            // let pos: Vec3 = new Vec3(-27, 0, -21);
            // let eulerAngles: Vec3 = new Vec3(0, 180, 0);
            // switch (i) {
            //     case 0:
            //         break;
            //     case 1:
            //         pos = new Vec3(23, 0, 18);
            //         eulerAngles = new Vec3(0, 0, 0);
            //         break;
            //     case 2:
            //         pos = new Vec3(23, 0, -21);
            //         eulerAngles = new Vec3(0, 180, 0);
            //         break;
            //     case 3:
            //         pos = new Vec3(-27, 0, 18);
            //         eulerAngles = new Vec3(0, 0, 0);
            //         break;
            // }
            player.id = i;
            // player.position = pos;
            // player.eulerAngles = eulerAngles;
            player.score = 0;
            player.hammerCount = 0;
            player.dizzyTime = 0;
            player.attackPos = null;
            player.attackId = -1;
            player.isScoreLead = false;
            player.camp = -1;
            players[i] = player;
            // let node = PoolManager.instance.getNode(this.virtualPlayerPrefab, this.node);
            // node.setWorldPosition(pos);
            // node.eulerAngles = eulerAngles;
            // this._dicPlayers[i] = node;
        }
        return players;
    }

    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.3/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.3/manual/zh/scripting/ccclass.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.3/manual/zh/scripting/life-cycle-callbacks.html
 */
